package com.dji.sample.manage.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dji.sample.manage.model.entity.DevicePositionEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Value;

import java.util.List;

/**
 * @author yjt
 * @date 2022-09-08
 * @description:
 */
public interface DevicePositionMapper extends BaseMapper<DevicePositionEntity> {

    @Select(value = "SELECT * from (" +
            "SELECT id,latitude,longitude,height from device_position where device_sn=#{deviceSn} and create_time>#{time} ORDER BY id asc limit 1) a" +
            " UNION " +
            "SELECT * from (" +
            "SELECT id,latitude,longitude,height from device_position where device_sn=#{deviceSn} ORDER BY id desc limit 1 ) a")
    List<DevicePositionEntity>  selectDevicePosition(@Param(value = "deviceSn") String deviceSn,@Param(value = "time") String time);
}
